﻿using MongoDB.Driver;
using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace HBKY.Shop.IRepository.MongoRepository
{

    public interface IMongoRepository<TEntity> where TEntity : class
    {
        IMongoQueryable<TEntity> Queryable { get; }
        IMongoCollection<TEntity> Collection { get; }
        Task AddAsync(TEntity entity);
        Task<TEntity> GetAsync(int Id);
        Task<List<TEntity>> GetListAsync();

        Task InsertOne(TEntity model);

        Task InsertMany(params TEntity[] modes);

        Task UpdateOne(Expression<Func<TEntity, bool>> filter, TEntity update);

        Task UpdateMany(Expression<Func<TEntity, bool>> filter, UpdateDefinition<TEntity> update);

        Task DeleteManyAsync(Expression<Func<TEntity, bool>> filter);

        Expression<Func<TEntity, TProperty>> ConvertToPropertyExpression<TProperty>(string propertyName);
    }
}
